Однако более привычный способ получить класс — использовать функцию type. Это также единственный способ, который работает для классов старого стиля.
>>> type([1, 2]) <class 'list'>
Кроме того, если вы хотите проверить, является ли некоторый объект экземпляром данного класса, следует использовать isinstance вместо прямого сравнения:
>>> class A: ... pass ... >>> class B(A): ... pass ... >>> type(B()) <class '__main__.B'> >>> isinstance(B(), A) True
Однако более привычный способ получить класс — использовать функцию type. Это также единственный способ, который работает для классов старого стиля.
>>> type([1, 2]) <class 'list'>
Кроме того, если вы хотите проверить, является ли некоторый объект экземпляром данного класса, следует использовать isinstance вместо прямого сравнения:
>>> class A: ... pass ... >>> class B(A): ... pass ... >>> type(B()) <class '__main__.B'> >>> isinstance(B(), A) True
At a time when the Indian stock market is peaking and has rallied immensely compared to global markets, there are companies that have not performed in the last 10 years. These are definitely a minor portion of the market considering there are hundreds of stocks that have turned multibagger since 2020. What went wrong with these stocks? Reasons vary from corporate governance, sectoral weakness, company specific and so on. But the more important question is, are these stocks worth buying?
Traders also expressed uncertainty about the situation with China Evergrande, as the indebted property company has not provided clarification about a key interest payment.In economic news, the Commerce Department reported an unexpected increase in U.S. new home sales in August.Crude oil prices climbed Friday and front-month WTI oil futures contracts saw gains for a fifth straight week amid tighter supplies. West Texas Intermediate Crude oil futures for November rose $0.68 or 0.9 percent at 73.98 a barrel. WTI Crude futures gained 2.8 percent for the week.
Библиотека Python разработчика | Книги по питону from id